import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DrawerBottomOpt extends StatefulWidget {
  DrawerBottomOpt({
    Key key,
    this.changeType,
    this.onRefresh,
    @required this.type,
    this.status,
  }):super(key:key);
  Function changeType;
  Function onRefresh;
  int type;
  int status;
  _DrawerBottomOptState createState() => _DrawerBottomOptState();
}

class _DrawerBottomOptState extends State<DrawerBottomOpt> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: ScreenUtil().setWidth(91),
      decoration: BoxDecoration(
        border: Border(
          top: BorderSide(
            width: ScreenUtil().setWidth(1),
            color: Color.fromRGBO(200, 200, 200, 1),
          )
        )
      ),
      child: Row(
        children: <Widget>[
          Container(
            width: ScreenUtil().setWidth(90),
            height: ScreenUtil().setWidth(90),
            child: Stack(
              children: <Widget>[
                Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(
                        IconData(widget.type == 1 ? 0xe62c : widget.type == 3 ? 0xe603 : 0xe6b6, fontFamily: 'iconfont'),
                        color: widget.type == 1 ? Colors.green[500] : widget.type == 3 ? Colors.red[500] : Colors.yellow[500],
                        size: ScreenUtil().setWidth(40),
                      ),
                      Text(
                        widget.type == 1 ? '在线' : widget.type == 3 ? '离线' : '忙碌',
                        style: TextStyle(
                          fontSize: ScreenUtil().setWidth(20)
                        ),
                      )
                    ],
                  )
                ),
                InkWell(
                  onTap: () {
                    showModalBottomSheet(
                      context: context,
                      builder: (BuildContext context){
                        return Column(
                          mainAxisSize: MainAxisSize.min,
                          children: <Widget>[
                            ListTile(
                              leading: Icon(IconData(0xe62c , fontFamily: 'iconfont')),
                              title: new Text("在线"),
                              onTap: () async {
                                Navigator.pop(context);
                                widget.changeType(1);
                              },
                            ),
                            ListTile(
                              leading: Icon(IconData(0xe6b6 , fontFamily: 'iconfont')),
                              title: new Text("忙碌"),
                              onTap: () async {
                                Navigator.pop(context);
                                widget.changeType(2);
                              },
                            ),
                            ListTile(
                              leading: Icon(IconData(0xe603 , fontFamily: 'iconfont')),
                              title: new Text("离线"),
                              onTap: () async {
                                Navigator.pop(context);
                                widget.changeType(3);
                              },
                            ),
                          ],
                        );
                      }
                    );
                  },
                )
              ],
            )
          ),
          Container(
            width: ScreenUtil().setWidth(90),
            height: ScreenUtil().setWidth(90),
            child: Stack(
              children: <Widget>[
                Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(
                        IconData(0xe6b9 , fontFamily: 'iconfont'),
                        color: widget.status == 1 ?Colors.blue : Colors.grey,
                        size: ScreenUtil().setWidth(40),
                      ),
                      Text(
                        widget.status == 1 ? '分配' : '不分配',
                        style: TextStyle(
                          fontSize: ScreenUtil().setWidth(20)
                        ),
                      )
                    ],
                  )
                ),
                InkWell(
                  onTap: () {
                    widget.onRefresh();
                  },
                )
              ],
            )
          ),
          Container(
            width: ScreenUtil().setWidth(90),
            height: ScreenUtil().setWidth(90),
            child: Stack(
              children: <Widget>[
                Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(
                        IconData(0xe69a , fontFamily: 'iconfont'),
                        color: Colors.grey,
                        size: ScreenUtil().setWidth(40),
                      ),
                      Text(
                        '刷新',
                        style: TextStyle(
                          fontSize: ScreenUtil().setWidth(20)
                        ),
                      )
                    ],
                  )
                ),
                InkWell(
                  onTap: () {
                    widget.onRefresh();
                  },
                )
              ],
            )
          ),
        ],
      ),
    );
  }
}